﻿using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            CodeTimers.CodeTimer.Initialize();
            int iteration = 10000000;
            Console.WriteLine("执行 {0}", iteration);
            CodeTimers.CodeTimer.Time("Null", iteration, () =>
            {
                new NullPropertyGetter(new Model1
                {
                    Sales1 = 0,
                    Title1 = 1,
                    Sales = 33,
                    Title = "标题",
                    Shipping = "23",
                    Author = "作者",
                    Store = "23",
                    Bestseller = "0",
                    Price = 0,
                    Publication = DateTime.Now
                }).GetNamedArguments();
            });

            //CodeTimers.CodeTimer.Time("expression", iteration, () =>
            //{
            //    new ExpressionPropertyGetter(new Model1
            //    {
            //        Sales1 = 0,
            //        Title1 = 1,
            //        Sales = 33,
            //        Title = "标题",
            //        Shipping = "23",
            //        Author = "作者",
            //        Store = "23",
            //        Bestseller = "0",
            //        Price = 0,
            //        Publication = DateTime.Now
            //    }).GetNamedArguments();
            //});

            CodeTimers.CodeTimer.Time("Emit DynamicMethod", iteration, () =>
            {
                new DynamicMethodPropertyGetter(new Model1
                {
                    Sales1 = 0,
                    Title1 = 1,
                    Sales = 33,
                    Title = "标题",
                    Shipping = "23",
                    Author = "作者",
                    Store = "23",
                    Bestseller = "0",
                    Price = 0,
                    Publication = DateTime.Now
                }).GetNamedArguments();
            });

            //CodeTimers.CodeTimer.Time("Emit TypeBuilder", iteration, () =>
            //{
            //    new TypeBuilderPropertyGetter(new Model1
            //    {
            //        Sales1 = 0,
            //        Title1 = 1,
            //        Sales = 33,
            //        Title = "标题",
            //        Shipping = "23",
            //        Author = "作者",
            //        Store = "23",
            //        Bestseller = "0",
            //        Price = 0,
            //        Publication = DateTime.Now
            //    }).GetNamedArguments();
    
            //});

            Console.ReadKey();

        }
    }

    public class Model1
    {
        public int Sales1 { get; set; }
        public int Title1 { get; set; }
        public double Sales { get; set; }
        public string Title { get; set; }
        public string Author { get; set; }
        public decimal Price { get; set; }
        public string Store { get; set; }
        public string Shipping { get; set; }
        public string Bestseller { get; set; }
        public DateTime Publication { get; set; }
    }

}
